home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / gcc / gcc261c.zoo / objects / HashTable.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-19  |  3.0 KB  |  108 lines

  1. /* Interface for Objective C NeXT-compatible HashTable object
  2.    Copyright (C) 1993,1994 Free Software Foundation, Inc.
  3.  
  4.    Written by:  R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
  5.    Date: May 1993
  6.  
  7.    This library is free software; you can redistribute it and/or
  8.    modify it under the terms of the GNU Library General Public
  9.    License as published by the Free Software Foundation; either
  10.    version 2 of the License, or (at your option) any later version.
  11.    
  12.    This library is distributed in the hope that it will be useful,
  13.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.    Library General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU Library General Public
  18.    License along with this library; if not, write to the Free
  19.    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */ 
  21.  
  22. /******************************************************************
  23.   TODO:
  24.    Does not implement methods for archiving itself.
  25.    Does not implement -freeKeys:values:.
  26. ******************************************************************/
  27.  
  28. #ifndef __HashTable_h_INCLUDE_GNU
  29. #define __HashTable_h_INCLUDE_GNU
  30.  
  31. #include <objc/Object.h>
  32. #include <objc/hash.h>
  33.  
  34. typedef node_ptr NXHashState;
  35.  
  36. @interface HashTable: Object
  37. {
  38.     unsigned    count;          /* Current number of associations */
  39.     const char  *keyDesc;       /* Description of keys */
  40.     const char  *valueDesc;     /* Description of values */
  41.     unsigned    _nbBuckets;     /* Current size of the array */
  42.     cache_ptr   _buckets;       /* Data array */
  43. }
  44. /* We include some instance vars we don't need so we are compatible
  45.    with NeXT programs that expect them to be there */
  46.  
  47.  
  48. /* Initializing */
  49.  
  50. - init;
  51. - initKeyDesc: (const char *)aKeyDesc;
  52. - initKeyDesc:(const char *)aKeyDesc 
  53.     valueDesc:(const char *)aValueDesc;
  54. - initKeyDesc: (const char *) aKeyDesc 
  55.     valueDesc: (const char *)aValueDesc 
  56.     capacity: (unsigned) aCapacity;
  57.  
  58. /* Freeing */
  59.  
  60. - free;
  61. - freeObjects;
  62. - freeKeys:(void (*) (void *))keyFunc 
  63.     values:(void (*) (void *))valueFunc;
  64. - empty;
  65.  
  66. /* Copying */
  67.  
  68. - shallowCopy;
  69. - deepen;
  70.   
  71. /* Manipulating */
  72.  
  73. - (unsigned)count;
  74. - (BOOL)isKey:(const void *)aKey;
  75. - (void *)valueForKey:(const void *)aKey;
  76. - (void *)insertKey:(const void *)aKey value:(void *)aValue;
  77. - (void *)removeKey:(const void *)aKey;
  78.  
  79. /* Iterating */
  80.  
  81. - (NXHashState)initState;
  82. - (BOOL)nextState:(NXHashState *)aState 
  83.     key:(const void **)aKey 
  84.     value:(void **)aValue;
  85.  
  86. /* Archiving */
  87.  
  88. - read: (TypedStream*)aStream;
  89. - write: (TypedStream*)aStream;
  90.  
  91. /* Old-style creation */
  92.  
  93. + newKeyDesc: (const char *)aKeyDesc;
  94. + newKeyDesc:(const char *)aKeyDesc 
  95.     valueDesc:(const char *)aValueDesc;
  96. + newKeyDesc:(const char *)aKeyDesc 
  97.     valueDesc:(const char *)aValueDesc
  98.     capacity:(unsigned)aCapacity;
  99.  
  100. /* Sending messages to elements of the hashtable */
  101.  
  102. - makeObjectsPerform:(SEL)aSel;
  103. - makeObjectsPerform:(SEL)aSel with:anObject;
  104.  
  105. @end
  106.  
  107. #endif /* __HashTable_h_INCLUDE_GNU */
  108.